package com.caregiver.watch.business.care.controller;

import com.caregiver.watch.business.care.model.dto.UpdateCareRecipientParam;
import com.caregiver.watch.business.care.model.vo.CareRecipientVo;
import com.caregiver.watch.business.care.service.CareRecipientService;
import com.caregiver.watch.common.domain.R;
import com.github.pagehelper.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Description: 被照护人服务
 * @Author 疆戟
 * @Date 2025/8/30 12:34
 * @Version 1.0
 */
@Tag(name  = "CareRecipientController", description = "被照护人服务")
@RestController
@RequestMapping("/care/recipient")
public class CareRecipientController {

    @Autowired
    private CareRecipientService careRecipientService;

    @Operation(summary = "查询被照护人列表", description = "查询被照护人列表")
    @GetMapping("queryCareRecipientList")
    public R<Page<CareRecipientVo>> queryCareRecipientList(@Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize) {
        return R.ok(careRecipientService.queryCareRecipientList(pageNum, pageSize));
    }

    @Operation(summary = "查询被照护人信息", description = "查询被照护人信息")
    @GetMapping("queryCareRecipientById")
    public R<CareRecipientVo> queryCareRecipientById(@Param("recipientId") Long recipientId) {
        return R.ok(careRecipientService.queryCareRecipientById(recipientId));
    }

    @Operation(summary = "修改被照护人", description = "修改被照护人")
    @PostMapping("updateCareRecipient")
    public R<Boolean> updateCareRecipient(@RequestBody UpdateCareRecipientParam updateCareRecipientParam) {
        return R.ok(careRecipientService.updateCareRecipient(updateCareRecipientParam));
    }

    @Operation(summary = "删除被照护人", description = "删除被照护人")
    @DeleteMapping("deleteCareRecipient")
    public R<Boolean> deleteCareRecipient(@RequestParam("recipientId") Long recipientId) {
        return R.ok(careRecipientService.deleteCareRecipient(recipientId));
    }
}
